package com.vancouver.knows.business.tracker;

import com.pangu.task.IResultReceiver;
import com.pangu.task.OperateResult;
import com.vancouver.knows.business.BusinessModule;
import com.vancouver.knows.business.bean.BusinessRateInfo;
import com.vancouver.knows.business.bean.CityDiscountDetailInfo;
import com.vancouver.knows.business.task.mark.UserRateTaskMark;

/**
 * 星级评论
 * @author chenxunlin01
 * 
 */
public class UserRateTracker extends ABInvokeTracker {

	public UserRateTracker(BusinessModule module, IResultReceiver resultReceiver) {
		super(module, resultReceiver);
	}

	@Override
	public String TAG() {
		return UserRateTracker.class.getSimpleName();
	}

	@Override
	public void handleResult(OperateResult result) {
		if(result.getResultData()!=null){
			BusinessRateInfo businessRateInfo = (BusinessRateInfo) result.getResultData();
			UserRateTaskMark taskMark = (UserRateTaskMark) result.getTaskMark();
			CityDiscountDetailInfo cityDiscountDetailInfo = module.getCacheManager().getDiscountDetailInfoMap()
					.get(taskMark.getPostId());
			if (cityDiscountDetailInfo != null) {
				cityDiscountDetailInfo.setUserRating(taskMark.getRating());
				cityDiscountDetailInfo.setBusinessRating(businessRateInfo.getRating());
				cityDiscountDetailInfo.setRatingCount(businessRateInfo.getRatingCount());
				cityDiscountDetailInfo.setRatingDetails(businessRateInfo.getRatingDetails());
			}
		}
	}
}
